package com.own.business.wallet.entity.bo;

import com.own.business.wallet.entity.po.Wallet;
import com.own.component.common.base.entity.BaseBo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * WalletBo
 *
 * @author chenxueli
 * @date 2023-07-13 16:07:39
 */
@Schema(title = "钱包" + ConstantBeanSuffix.BO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class WalletBo extends BaseBo<Wallet> implements Serializable {

    @Schema(title = "用户id")
    private Long userId;

    @Schema(title = "余额（分）")
    private Integer balance;

    @Schema(title = "冻结金额（分）")
    private Integer freezeAmount;

    @Schema(title = "支付密码")
    private String password;

    @Schema(title = "是否设置免密支付（0=未设置 1=已设置）")
    private Integer isWithoutPassword;

    /**
     * 转持久化对象
     *
     * @param entity 原持久化对象
     * @return 持久化对象
     */
    @Override
    public Wallet toPo(Wallet entity) {
        if (entity == null) {
            entity = new Wallet();
        }
        entity.setFkUserId(this.userId);
        entity.setBalance(this.balance);
        entity.setFreezeAmount(this.freezeAmount);
        entity.setPassword(this.password);
        entity.setIsWithoutPassword(this.isWithoutPassword);
        return super.toPo(entity);
    }

}

